#ifndef __MOVTWN
#define __MOVTWN	1

#ifdef ALONE_MOVTWN
#include <windows.h>
#include <stdio.h>

#include "ApmsApi.h"
#include "ApmsUtility.h"
#include "Tianwan.h"
#include "Uti_Tianwan.h"
#include "XlsObj.h"
#include "Twn_TNTBuilder.h"
#define APISRV extern "C" __declspec(dllexport)
#else
#define APISRV extern "C" __declspec(dllimport)
#endif


/**********************************************
*GET/SET/CHECK/RESET/UPDATE DYNAMIC PARAMETERS*
**********************************************/


/* *** Get Current Phase from Dynamic Parameters ***/

APISRV RETSTAT GetDynCurrentPhase	( int	*Current_Phase );

/* *** Set Current Phase in Dynamic Parameters ***/

APISRV RETSTAT SetDynCurrentPhase	( int	Current_Phase );

/* *** Get Next Phase from Dynamic Parameters ***/

APISRV RETSTAT GetDynNextPhase		( int	*Next_Phase );

/* *** Set Next Phase in Dynamic Parameters ***/

APISRV RETSTAT SetDynNextPhase		( int	Next_Phase );

/* *** Get Next Move_a from Dynamic Parameters ***/

APISRV RETSTAT GetDynNextMove_a	( int	*Next_Move_a );

/* *** Set Next Move_a in Dynamic Parameters ***/

APISRV RETSTAT SetDynNextMove_a	( int	Next_Move_a );

/* *** Get Current Mode from Dynamic Parameters ***/

APISRV RETSTAT GetDynCurrentMode	( int	*CurrentMode );

/* *** Set Current Mode in Dynamic Parameters ***/

APISRV RETSTAT SetDynCurrentMode	( int	CurrentMode );

/* *** Get Current Operation from Dynamic Parameters ***/

APISRV RETSTAT GetDynCurrentOper	( int *Current_ope );

/* *** Set Current Operation in Dynamic Parameters ***/

APISRV RETSTAT SetDynCurrentOper	( int Current_ope );

/* *** Check if an Object Type is currently on Mast ***/

APISRV RETSTAT CheckDynCurrObjt	(GENIDX ObjtIdx);

/* *** Check if NO one Object is currently on Mast ***/

APISRV RETSTAT CheckDynCurrNoObjt	( void );

/* *** Reset Object Type on Mast ***/

APISRV RETSTAT ResDynCurrObjt	( void );

APISRV RETSTAT SetDynCurrentMast	(GENIDX Current_mm);

APISRV RETSTAT GetDynCurrentMast	(GENIDX *Current_mm);


/*************************
**FUNCTION TO MOVE OBJECT*
/************************/


/* *** Get Actual Cell Situation using Virtual Coordinate ***/

APISRV RETSTAT GetCellSituation	( int VCoo_X, int VCoo_Y, OBJTCELL *ObjtCell );

/* *** Update Cell Situation with new Situation using Virt. Coord. ***/

APISRV RETSTAT UpdateCellSituation(int VCoo_X, int VCoo_Y, OBJTCELL *NewObjtCell );

/* *** Get Actual Mast Situation ***/

APISRV RETSTAT GetMastSituation(OBJTMM *ObjtMast);

/* *** Update Mast Situation with new Situation ***/

APISRV RETSTAT UpdateMastSituation(OBJTMM *NewObjtMast);

/* *** Change Object Type in Cell Situation ***/

APISRV RETSTAT CngObjtInCellSituation(OBJTCELL *ObjtCell, GENIDX ObjectIdx, GENIDX NewObjtIdx);

/* *** Put Object in Cell Situation ***/

APISRV RETSTAT PutObjectInCellSituation	( OBJTCELL *ObjtCell, GENIDX ObjectIdx,
					GENIDX ObjtIdx );

/* *** Insr Object in Cell Situation ***/

APISRV RETSTAT InsObjectInCellSituation(OBJTCELL *ObjtCell, GENIDX ObjectIdx, GENIDX ObjtIdx);

/* *** Get Object from Cell Situation ***/

APISRV RETSTAT GetObjectFromCellSituation	( OBJTCELL *ObjtCell, GENIDX ObjectIdx,
					GENIDX ObjtIdx );

/* *** Put Object in Mast Situation ***/

APISRV RETSTAT PutObjectInMastSituation	( OBJTMM *ObjtMast, GENIDX ObjtIdx );

/* *** Get Object from Mast Situation ***/

APISRV RETSTAT GetObjectFromMastSituation	( OBJTMM *ObjtMast, GENIDX ObjtIdx );

/* *** Insert Object in Cell and Remove from Mast ***/

APISRV RETSTAT InsertObject(OBJTCELL *ObjtCell, OBJTMM *ObjtMast, GENIDX ObjectIdx, GENIDX ObjtIdx, int cellType);

/* *** Remove Object from Cell and Insert in Mast ***/

APISRV RETSTAT RemoveObject	(OBJTCELL *ObjtCell, OBJTMM *ObjtMast, GENIDX ObjectIdx, GENIDX ObjtIdx );

/**************************************
**FUNCTION TO MANAGE MICRO CMD EXECUTE*
**************************************/


/* *** Initialize Micro Cmd Exe File for new Phase ***/

APISRV RETSTAT	InitMicroCmdExe(void);

/* ** Get Main Mast Actual Position from TAGS in DB ***/

APISRV RETSTAT Get_Mast_Info(mast_info *Info);

/* ** Get Main Mast TV Position from TAGS in DB ***/

APISRV RETSTAT Get_Mast_TV_Pos(float *Angle);

APISRV RETSTAT CheckMastMounted(GENIDX mastIdx);

APISRV RETSTAT GetDynTVAngle(float *angle);
APISRV RETSTAT SetDynTVAngle(float angle);
APISRV RETSTAT InsertObjectEx(short int vx, short int vy,  OBJTCELL	*ObjtCell, OBJTMM *ObjtMast, GENIDX ObjectIdx, GENIDX ObjtIdx);
#endif